import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home'
import vShuju from '@/components/vShuju';
import vStudent from '@/components/vStudent';
import vTeacher from '@/components/vTeacher';
import vSubject from '@/components/vSubject';
import vClass from '@/components/vClass';

Vue.use(VueRouter)

//解决路由版本引起的错误方案1： 添加这下面一段代码，就可以解决报错 
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

//解决路由版本引起的错误方案2：
// npm i vue-router@3.0 -S

  	const routes = [
		{
			path: '/',
			redirect:'/home/shuju'
		},
		{
			path:'/home',
			name:'home',
			component: Home,
			children:[
				{
					path:'shuju',
					name:'vShuju',
					component:vShuju
				},{
					path:'student/:id',
					name:'vStudent',
					component:vStudent
				},{
					path:'teacher',
					name:'vTeacher',
					component:vTeacher
				},{
					path:'class',
					name:'vClass',
					component:vClass
				},{
					path:'subject',
					name:'vSubject',
					component:vSubject
				},
				// {
				// 	path:'/',
				// 	redirect:'shuju'
				// }
			]
		}
	]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})



export default router
